(define (make-account balance password)
  (define (withdraw amount)
    (if (>= balance amount)
      (begin (set! balance (- balance amount))
             balance)
      "Insufficient funds"))
  (define (verify pwd)
    (if (eq? pwd password) #t (begin (error "Incorrect password") #f)))
  (define (deposit amount)
    (set! balance (+ balance amount))
    balance)
  (define (dispatch p m)
    (cond ((eq? m 'withdraw) (if (eq? (verify p) #t) withdraw))
          ((eq? m 'deposit) (if (eq? (verify p) #t) deposit))
          ((eq? m 'verify) (verify p))
          (else (error "Unknow request -- MAKE-ACCOUNT"))))
  dispatch)

(define (make-joint account password new-password)
  (define (withdraw)
    (account password 'withdraw))
  (define (verify-origin-password)
    (if (eq? (account password 'verify) #t) #t #f))
  (define (verify pwd)
    (if (eq? pwd new-password) #t (begin (error "Incorrect password") #f)))
  (define (deposit)
    (account password 'deposit))
  (define (dispatch p m)
    (cond ((eq? m 'withdraw) (if (eq? (verify p) #t) (withdraw)))
          ((eq? m 'deposit) (if (eq? (verify p) #t) (deposit)))
          (else (error "Unknow request -- MAKE-ACCOUNT"))))
  (if (verify-origin-password)
    dispatch))

(define origin-account (make-account 1000 '123))

((origin-account '123 'withdraw) 100)

(define joint-account (make-joint origin-account '123 '321))

((joint-account '321 'withdraw) 100)

((origin-account '123 'withdraw) 100)
